package com.nuanshui.heatedloan.util;

public class UserAuthUtil {
	
	/**
	 * 
	 * @param auth 权限
	 * @param authIndex 要增加的权限
	 */
	public static  long addAuth(long  auth,int authIndex) {
		long i= 1;
		i =  i<<authIndex-1;
		return auth|i;
				
	}
	
	public static  long delAuth(long auth,int authIndex) {
		long  i = 1;
		i = i<<authIndex-1;
		i = ~i;
		return auth&i;
		
	}
	
	public static  boolean hasAuth(Long auth,int authIndex) {
		long i= 1;
		i =  i<<authIndex-1;
		auth = auth&i;
		if(auth>0) return true;
		return  false;
	}
	
	public static void main(String[] args) {
		long auth = 3;
		//111    1 2 4
		
		 System.out.println(addAuth(auth,3));
		 System.out.println(delAuth(auth, 2));
		 System.out.println(hasAuth(auth, 2));
		
		
	}

}
